package com.ngmaster.socket.message;

import com.ngmaster.socket.ProtocolMessage;
import io.swagger.annotations.ApiModelProperty;

import java.util.Arrays;

/**
 * 修改心跳周期
 * 接收应答一致:
 */
public class UpdateHeartbeatIntervalMessage extends ProtocolMessage {

    /** 秒间隔 */
    @ApiModelProperty(value = "心跳间隔,单位秒", example = "0x003C")
    private byte interval;

    public byte getInterval() {
        return interval;
    }

    public void setInterval(byte interval) {
        this.interval = interval;
    }

    @Override
    public void onSerial() {
        this.byteArray.writeByte(this.interval);
    }

    @Override
    public void onDeserialize() {
        this.interval = this.byteArray.readByte();
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("UpdateHeartbeatIntervalMessage{");
        sb.append("interval=").append(interval);
        sb.append(", imeiBytes=").append(Arrays.toString(imeiBytes));
        sb.append(", imei='").append(imei).append('\'');
        sb.append(", cmd=").append(cmd);
        sb.append(", dataLength=").append(dataLength);
        sb.append(", crc=").append(crc);
        sb.append(", crcHex='").append(crcHex).append('\'');
        sb.append(", byteArray=").append(byteArray);
        sb.append('}');
        return sb.toString();
    }
}
